<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags"  prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>添加用户角色</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" type="text/css"
			href="./styles/control_panel.css" />
	<script type="text/javascript">
		function callBack(){
			window.history.back();
		}
	</script>
		<jsp:include page="../../rapid-validation.jsp"></jsp:include>
<script type="text/javascript">
	var xmlHttp;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}
function validateRole() {  
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    var roleName = document.getElementById("roleName").value;
    var url =  "bbs/role/role_validateData.action?time=" + new Date().getTime() + "&role=" + roleName;
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader("content-type",
				"application/x-www-form-urlencoded;charset=utf-8");
    xmlHttp.send(null);
}    
function handleStateChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
           var doc = xmlHttp.responseText;
           var menuNameError = document.getElementById("roleNameError");
           	menuNameError.innerHTML = doc;
          		 }
        }
}


function testResource(){
	var roleNameError = document.getElementById("roleNameError");
	if(roleNameError.firstChild.getAttribute("color")=="#ff0000"){
		alert("角色名已存在，请修改后再提交");
		return false;
	}else{
		return true;
	}
	
}
</script>
  </head>
  
  <body>
  	<div style="margin-bottom: 4px; margin-left: 12px;" align="center">
		<div
			style="border: 1px solid #cccccc; height: auto !important; height: 100px; min-height: 100px;">
			<div class="control_con_right_0021">
				<table width="100%" cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td align="left" class="tb_left" valign="middle" colspan="3"
							style="padding-left: 10px;">
							添加角色
						</td>
					</tr>
				</table>
			</div>
     <form action="bbs/role/role_addRole.action" method="post" id="form1" name="form1" onsubmit="if(!testResource()){return false;}">
    	<table>
			<tr height="30px">
				<td align="left">角色名：</td>
				<td><input type="text" name="role" id="roleName" onblur="validateRole();" class="required"/><font color="red">*</font><span id="roleNameError"></span></td>
			</tr>
			<tr height="30px">
				<td align="left">角色状态：</td>
				<td>
					<select name="statue" class="validate-selection">
						<option>请选择</option>
						<option value="SOA">有效</option>
						<option value="SOX">无效</option>
					</select><font color="red">*</font>
				</td>
			</tr>
			<tr height="30px">
				<td align="left">角色属性</td>
				<td>
					   <SELECT name="attr" class="validate-selection" >
					   	  <option>请选择</option>
					      <option value="00">普通用户属性码</option>
					       <optgroup label="技术板块属性码">
					         <option value="1"> >技术板块超级版主</option>
					         <option value="6"> >指标实战板块版主</option>
					         <option value="7"> >K线/切线板块版主</option>
					          <option value="8"> >波浪理论板块版主</option>
					       </optgroup>
					        <optgroup label="基本面板板块属性码">
					         <option value="20"> >基本面板板块超级版主</option>
					          
					       </optgroup>
					   </SELECT><font color="red">*</font>
				</td>
			</tr>
			<tr height="50px">
				<td align="left">备注：</td>
				<td>
					<s:textarea name="remark" theme="simple" rows="5" cssClass="max-length-200"></s:textarea>
				</td>
			</tr>
			<tr height="40px">
				<td colspan="2" align="center">
					<input type="submit" value="提交" >&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="button" value="返回" onclick="callBack();">
				</td>
			</tr>
		</table>
    </form>
    </div>
    </div>
     <script>
new Validation('form1', {
	immediate : true
});
</script>
  </body>
</html>
